*** Estimated with Stata 15.1 Revision Jul 8, 2021
  * and the following user-written commands:
	* reghdfe (version 5.7.3 13nov2019)
	* coefplot (version 1.8.4 17dec2020)
	* grstyle (version 1.1.1 15sep2020)
	* binscatter (version 7.02 24nov2013)
	* outreg2 (version 2.3.2 17aug2014)
	* ftools (version 2.37.0 16aug2019)
	* ranktest (2.0.04  21sept2020)
	* tuples (4.0.3 16may2021)
	* ivreg2 (4.1.11 22nov2019)
	* parmest (SJ10-4 st0043_2 07 October 2015)
	
	

clear
clear matrix
clear mata
set more off
set maxvar 32767

use HLR_data, clear
capture log using "HLR.smcl", replace

global filters="nexamined>=10 & tc<39 & year_action<2010 & rounds_before_patent_FA<5 & patent_approved==1"
global filtersNC="nexamined_nc>=10 & tc<39 & year_action<2010 & rounds_before_patent_FA<5 & patent_approved==1"
global filtersCCD="nexamined>=10 & tc<39 & year_action<2010 & rounds_before_patent_FA<5 & pat_approved_ccd==1"
global filtersVC="!(made_it_to_next_round_`i'y==0 & first_pat_act_date+365.25*`i'>= Exit_Date)"
global filtersRejected="nexamined>=10 & tc<39 & year_action<2010 & rounds_before_patent_FA<5 & patent_approved==0"


****************
*** FIGURE 1 ***
****************

use HLR_data, clear
xi: reghdfe pat_clm_ct instrument_ind_claims, absorb(ind_year_fe state_num) vce(cluster gau)
	g sample=e(sample)
xi: areg instrument_ind_claims if sample==1, absorb(ind_year_fe) robust cluster(gau)
	predict error_scope if e(sample), residuals
drop sample 

xi: reghdfe lag_app_to_first_action instrument_lag if dallowed==1, absorb(ind_year_fe state_num) vce(cluster gau)
	g sample=e(sample)
xi: areg instrument_lag if sample==1, absorb(ind_year_fe) robust cluster(gau)
	predict error_timing if e(sample), residuals
drop sample

scatter error_scope error_timing if error_scope>=-4 & error_scope<=4, ytitle("Examiner average independent claims per patent (residual)") xtitle("Examiner average first-action examination time (residual)") graphregion(color(white)) 
binscatter error_scope error_timing if error_scope>=-4 & error_scope<=4, ytitle("Examiner average independent claims per patent (residual)") xtitle("Examiner average first-action examination time (residual)") graphregion(color(white)) nquantiles(100)
drop error_scope error_timing


****************
*** FIGURE 2 ***
****************

use HLR_data, clear
xi: reghdfe pat_clm_ct instrument_ind_claims, absorb(ind_year_fe state_num) vce(cluster gau)
	g sample=e(sample)
xi: areg instrument_ind_claims if sample==1, absorb(ind_year_fe) robust cluster(gau)
	predict error if e(sample), residuals
	su error if sample==1, d
histogram error if error>=-4 & error<=4, frac xtitle("Examiner average independent claims per patent (residual)") xlabel(-4(1)4) graphregion(color(white)) color(gs8) lcolor(black)
drop sample error


****************
*** FIGURE 3 ***
****************

use HLR_data, clear
xi: reghdfe lag_app_to_first_action instrument_lag if dallowed==1, absorb(ind_year_fe state_num) vce(cluster gau)
	g sample=e(sample)
xi: areg instrument_lag if sample==1, absorb(ind_year_fe) robust cluster(gau)
	predict error if e(sample), residuals
	su error if sample==1, d
histogram error, frac start(-4) width(0.2) xtitle("Examiner average first-action examination time (residual)") xlabel(-4(2)4) graphregion(color(white)) color(gs8) lcolor(black)
drop sample error


****************
*** FIGURE 4 ***
****************

use HLR_Fig4_Data, clear

* Panel A, Employment Growth
mkmat estimate_ min95_ max95_ if parm=="pat_clm_ct" & dv=="Employment Growth", matrix(D)
matrix E=D'
matrix list E
matrix colnames E=-3 -2 -1 1 2 3 4 5

coefplot matrix(E), title("Employment Growth", size(large)) vertical b((1)) ci((2 3)) ciopts(recast(rcap)) yline(0, lcolor(red) lpattern(solid) lwidth(medium)) graphregion(fcolor(white)) 
graph save fr12_panela_emp.gph, replace

* Panel A, Sales Growth
mkmat estimate_ min95_ max95_ if parm=="pat_clm_ct" & dv=="Sales Growth", matrix(D)
matrix E=D'
matrix list E
matrix colnames E=-3 -2 -1 1 2 3 4 5
 
coefplot matrix(E), title("Sales Growth", size(large)) vertical b((1)) ci((2 3)) ciopts(recast(rcap)) yline(0, lcolor(red) lpattern(solid) lwidth(medium)) graphregion(fcolor(white)) 
graph save fr12_panela_sales.gph, replace

* Panel A, VC
mkmat estimate_ min95_ max95_ if parm=="pat_clm_ct" & dv=="Venture Capital Funding", matrix(D)
matrix E=D'
matrix list E
matrix colnames E=-3 -2 -1 1 2 3 4 5
 
coefplot matrix(E), title("Venture Capital Funding", size(large)) vertical b((1)) ci((2 3)) ciopts(recast(rcap)) yline(0, lcolor(red) lpattern(solid) lwidth(medium)) graphregion(fcolor(white)) 
graph save fr12_panela_vc.gph, replace

gr combine fr12_panela_emp.gph fr12_panela_sales.gph fr12_panela_vc.gph, graphregion(fcolor(white)) b1("Year", size(large)) rows(1)
graph display, ysize(2.5) xsize(8) 
 
* Panel B, Employment Growth
mkmat estimate_ min95_ max95_ if parm=="lag_app_to_first_action" & dv=="Employment Growth", matrix(D)
matrix E=D'
matrix list E
matrix colnames E=-3 -2 -1 1 2 3 4 5

coefplot matrix(E), title("Employment Growth", size(large)) vertical b((1)) ci((2 3)) ciopts(recast(rcap)) yline(0, lcolor(red) lpattern(solid) lwidth(medium)) graphregion(fcolor(white)) 
graph save fr12_panelb_emp.gph, replace

* Panel B, Sales Growth
mkmat estimate_ min95_ max95_ if parm=="lag_app_to_first_action" & dv=="Sales Growth", matrix(D)
matrix E=D'
matrix list E
matrix colnames E=-3 -2 -1 1 2 3 4 5

coefplot matrix(E), title("Sales Growth", size(large)) vertical b((1)) ci((2 3)) ciopts(recast(rcap)) yline(0, lcolor(red) lpattern(solid) lwidth(medium)) graphregion(fcolor(white)) 
graph save fr12_panelb_sales.gph, replace

* Panel B, VC
mkmat estimate_ min95_ max95_ if parm=="lag_app_to_first_action" & dv=="Venture Capital Funding", matrix(D)
matrix E=D'
matrix list E
matrix colnames E=-3 -2 -1 1 2 3 4 5
 
coefplot matrix(E), title("Venture Capital Funding", size(large)) vertical b((1)) ci((2 3)) ciopts(recast(rcap)) yline(0, lcolor(red) lpattern(solid) lwidth(medium)) graphregion(fcolor(white)) 
graph save fr12_panelb_vc.gph, replace

gr combine fr12_panelb_emp.gph fr12_panelb_sales.gph fr12_panelb_vc.gph, graphregion(fcolor(white)) b1("Year", size(large)) rows(1)
graph display, ysize(2.5) xsize(8) 


***************
*** TABLE 1 ***
***************

use HLR_data, clear
* Number of firms, scope and leniency
tabstat pat_clm_ct lag_app_to_first_action if (patent_approved==1 & pat_clm_ct!=. & lag_app_to_first_action!=.), statistics(mean median sd count)

* Panel A: Pre-filing Characteristics
tabstat age_application initial_app_emp_w initial_app_sales_def_w growth_p1_emp_w growth_p1_sales_w if (patent_approved==1 & pat_clm_ct!=. & lag_app_to_first_action!=.), statistics(mean median sd count)

* Panel B: Subsequent Growth in Employment and Sales
tabstat growth1_emp_w growth3_emp_w growth5_emp_w growth1_sales_w growth3_sales_w growth5_sales_w if (patent_approved==1 & pat_clm_ct!=. & lag_app_to_first_action!=.), statistics(mean median sd count)
	
* Panel C: Subsequent Innovation
tabstat total_patents_appl total_patents_approved approval_rate all_cites5 mean_cites5 if (patent_approved==1 & pat_clm_ct!=. & lag_app_to_first_action!=.), statistics(mean median sd count)

* Panel D: VC/Exit variables
tabstat made_it_to_next_round IPO if (patent_approved==1 & pat_clm_ct!=. & lag_app_to_first_action!=.), statistics(mean median sd count)
	

************************
*** TABLE 2, PANEL A ***
************************

use HLR_data, clear
foreach dv in pat_clm_ct {
	g iv=instrument_ind_claims

	* Column 1: 
	xi: reghdfe `dv' iv instrument_lag if patent_approved==1, absorb(ind_year_fe state_num) vce(cluster gau)
		test iv
		local F=r(F)
		outreg2 using "Table2A.xls", dec(3) replace keep(iv instrument_lag) noparen nocons addstat("F-test: IV",`F')
	* Column 2: 
	xi: reghdfe `dv' iv instrument_lag ln_initial_emp ln_initial_sales age_application_w if patent_approved==1, absorb(ind_year_fe state_num) vce(cluster gau)
		test iv
		local F=r(F)
		outreg2 using "Table2A.xls", dec(3) append keep(iv instrument_lag ln_initial_emp ln_initial_sales age_application_w) noparen nocons addstat("F-test: IV",`F')
	* Column 3: 
	xi: reghdfe `dv' iv instrument_lag growth_p1_emp_w growth_p1_sales_w if patent_approved==1, absorb(ind_year_fe state_num) vce(cluster gau)
		test iv
		local F=r(F)
		outreg2 using "Table2A.xls", dec(3) append keep(iv instrument_lag growth_p1_emp_w growth_p1_sales_w) noparen nocons addstat("F-test: IV",`F')
	* Column 4: 
	xi: reghdfe `dv' iv instrument_lag if patent_approved==1, absorb(ind_year_fe techsc_year_fe state_num) vce(cluster gau)
		test iv
		local F=r(F)
		outreg2 using "Table2A.xls", dec(3) append keep(iv instrument_lag) noparen nocons addstat("F-test: IV",`F')
	* Column 5: 
	xi: reghdfe `dv' iv instrument_lag i.exgrade_fe ln_extenure if patent_approved==1, absorb(ind_year_fe techsc_year_fe state_num) vce(cluster gau)
		test iv
		local F=r(F)
		outreg2 using "Table2A.xls", dec(3) append keep(iv instrument_lag ln_extenure _Iexgrade_f_2 _Iexgrade_f_3 _Iexgrade_f_4 _Iexgrade_f_5 _Iexgrade_f_6 _Iexgrade_f_7) sortvar(iv instrument_lag ln_initial_emp ln_initial_sales age_application_w growth_p1_emp_w growth_p1_sales_w ln_extenure _Iexgrade_f_2 _Iexgrade_f_3 _Iexgrade_f_4 _Iexgrade_f_5 _Iexgrade_f_6 _Iexgrade_f_7) noparen nocons addstat("F-test: IV",`F')
		
		drop iv
}


**********************
* TABLE 2, PANEL B ***
**********************

use HLR_data, clear
foreach dv in lag_app_to_first_action {
	g iv=instrument_lag

	* Column 1: 
	xi: reghdfe `dv' iv instrument_ind_claims if patent_approved==1, absorb(ind_year_fe state_num) vce(cluster gau)
		test iv
		local F=r(F)
		outreg2 using "Table2B.xls", dec(3) replace keep(iv instrument_ind_claims) addstat("F-test: IV",`F') noparen nocons
	* Column 2: 
	xi: reghdfe `dv' iv instrument_ind_claims ln_initial_emp ln_initial_sales age_application_w if patent_approved==1, absorb(ind_year_fe state_num) vce(cluster gau)
		test iv
		local F=r(F)
		outreg2 using "Table2B.xls", dec(3) append keep(iv instrument_ind_claims ln_initial_emp ln_initial_sales age_application_w) addstat("F-test: IV",`F') noparen nocons
	* Column 3: 
	xi: reghdfe `dv' iv instrument_ind_claims growth_p1_emp_w growth_p1_sales_w if patent_approved==1, absorb(ind_year_fe state_num) vce(cluster gau)
		test iv
		local F=r(F)
		outreg2 using "Table2B.xls", dec(3) append keep(iv instrument_ind_claims growth_p1_emp_w growth_p1_sales_w) addstat("F-test: IV",`F') noparen nocons
	* Column 4: 
	xi: reghdfe `dv' iv instrument_ind_claims if patent_approved==1, absorb(ind_year_fe techsc_year_fe state_num) vce(cluster gau)
		test iv
		local F=r(F)
		outreg2 using "Table2B.xls", dec(3) append keep(iv instrument_ind_claims) addstat("F-test: IV",`F') noparen nocons
	* Column 5: 
	xi: reghdfe `dv' iv instrument_ind_claims i.exgrade_fe ln_extenure if patent_approved==1, absorb(ind_year_fe techsc_year_fe state_num) vce(cluster gau)
		test iv
		local F=r(F)
		outreg2 using "Table2B.xls", dec(3) append keep(iv instrument_ind_claims ln_extenure _Iexgrade_f_2 _Iexgrade_f_3 _Iexgrade_f_4 _Iexgrade_f_5 _Iexgrade_f_6 _Iexgrade_f_7) sortvar(iv instrument_ind_claims ln_initial_emp ln_initial_sales age_application_w growth_p1_emp_w growth_p1_sales_w ln_extenure _Iexgrade_f_2 _Iexgrade_f_3 _Iexgrade_f_4 _Iexgrade_f_5 _Iexgrade_f_6 _Iexgrade_f_7) noparen nocons addstat("F-test: IV",`F') 
		
		drop iv
}


*******************************
*** TABLE 3, PANELS A AND B ***
*******************************

use HLR_data, clear
foreach instrument in instrument_ind_claims instrument_lag {
	* Column 1: 
	xi: reghdfe `instrument' ln_initial_app_emp ln_initial_app_sales age_application_w, absorb(ind_year_fe state_num) vce(cluster gau)
		outreg2 using "Table3.xls", dec(3) append keep(ln_initial_app_emp ln_initial_app_sales age_application_w) noparen nocons
	* Column 2: 
	xi: reghdfe `instrument' growth_p1_emp_w growth_p1_sales_w, absorb(ind_year_fe state_num) vce(cluster gau)
		outreg2 using "Table3.xls", dec(3) append keep(growth_p1_emp_w growth_p1_sales_w) noparen nocons
	* Column 3: 
	xi: reghdfe `instrument' pub_clm_ct avg_pub_clm_wrd_ct backwards_cites npl_cites, absorb(ind_year_fe techsc_year_fe state_num) vce(cluster gau)
		outreg2 using "Table3.xls", dec(3) append keep(pub_clm_ct avg_pub_clm_wrd_ct backwards_cites npl_cites) noparen nocons
	* Column 4: 
	xi: reghdfe `instrument' grant_eu if appl_eu==1, absorb(ind_year_fe state_num) vce(cluster gau)
		outreg2 using "Table3.xls", dec(3) append keep(grant_eu) noparen nocons
	* Column 5: 
	xi: reghdfe `instrument' grant_jp if appl_jp==1, absorb(ind_year_fe state_num) vce(cluster gau)
		outreg2 using "Table3.xls", dec(3) append keep(grant_jp) noparen nocons
}


**********************************
**** TABLE 4, PANELS A AND B *****
*** TABLE IA.1, PANELS A AND B ***
**********************************

use HLR_data, clear
foreach var in emp sales {
	forvalues i= 1(1)5 {
		global controls="ln_initial_`var'"
		reghdfe growth`i'_`var'_w $controls (pat_clm_ct lag_app_to_first_action=instrument_lag instrument_ind_claims) if $filters, absorb(i.state_num ind_year_fe) cluster(gau) old
			local KPFstat=e(widstat)
			su growth`i'_`var'_w if e(sample)==1
			local mean=r(mean)
			outreg2 using "Table4.xls", dec(3) addstat("KP F-stat",`KPFstat',"Mean dep var",`mean') sortvar(pat_clm_ct lag_app_to_first_action) keep(pat_clm_ct lag_app_to_first_action) append noparen nor2
			g sample=e(sample)
		reghdfe growth`i'_`var'_w pat_clm_ct lag_app_to_first_action $controls if $filters & sample==1, absorb(i.state_num ind_year_fe) cluster(gau) 
			su growth`i'_`var'_w if e(sample)==1
			local mean=r(mean)
			outreg2 using "Table_IA1.xls", dec(3) addstat("Mean dep var",`mean') sortvar(pat_clm_ct lag_app_to_first_action) keep(pat_clm_ct lag_app_to_first_action) append noparen nocons
		drop sample
	}
}


***************************
**** TABLE 4, PANEL C *****
*** TABLE IA.1, PANEL C ***
***************************

use HLR_data, clear
forvalues i=1(1)5 {
	global controls="ln_initial_emp"
	reghdfe survive`i' $controls (pat_clm_ct lag_app_to_first_action=instrument_lag instrument_ind_claims) if $filters, absorb(i.state_num ind_year_fe) cluster(gau) old
		local KPFstat=e(widstat)
		su survive`i' if e(sample)==1
		local mean=r(mean)
		outreg2 using "Table4.xls", dec(3) addstat("KP F-stat",`KPFstat',"Mean dep var",`mean') keep(pat_clm_ct lag_app_to_first_action) sortvar(pat_clm_ct lag_app_to_first_action) append noparen nor2
		g sample=e(sample)
	reghdfe survive`i' pat_clm_ct lag_app_to_first_action $controls if $filters & sample==1, absorb(i.state_num ind_year_fe) cluster(gau) 
		su survive`i' if e(sample)==1
		local mean=r(mean)
		outreg2 using "Table_IA1.xls", dec(3) addstat("Mean dep var",`mean') keep(pat_clm_ct lag_app_to_first_action) sortvar(pat_clm_ct lag_app_to_first_action) append noparen nocons
	drop sample
}


***************
*** TABLE 5 ***
***************

use HLR_data, clear
foreach var in emp sales {
	forvalues i= 1(1)5 {
		global controls="ln_initial_`var'"
		reghdfe growth`i'_`var'_w $controls (pat_clm_ct lag_app_to_first_action=instrument_lag instrument_ind_claims) if $filters & survive`i'==1, absorb(i.state_num ind_year_fe) cluster(gau) old
			local KPFstat=e(widstat)
			su growth`i'_`var'_w if e(sample)==1
			local mean=r(mean)
			outreg2 using "Table5.xls", dec(3) addstat("KP F-stat",`KPFstat',"Mean dep var",`mean') keep(pat_clm_ct lag_app_to_first_action) sortvar(pat_clm_ct lag_app_to_first_action) append noparen nor2
	}
}


***************
*** TABLE 6 ***
***************

use HLR_data, clear

* Cols. 1-5: VC funding
forvalues i=1/5 {
	global controls="ln_rounds_before_patent_FA"
	global filtersVC="!(made_it_to_next_round_`i'y==0 & first_pat_act_date+365.25*`i'>= Exit_Date)"
	xi: reghdfe made_it_to_next_round_`i'y $controls (pat_clm_ct lag_app_to_first_action=instrument_lag instrument_ind_claims) if $filters & $filtersVC, absorb(ind_year_fe state_fe) vce(cluster gau) old
			local KPFstat=e(widstat)
			su made_it_to_next_round_`i'y if e(sample)==1
			local mean=r(mean)
			outreg2 using "Table6.xls", dec(3) addstat("KP F-stat",`KPFstat',"Mean dep var",`mean') keep(pat_clm_ct lag_app_to_first_action ln_rounds_before_patent_FA) append noparen nor2
			g sample=e(sample)
		quietly reghdfe made_it_to_next_round_`i'y pat_clm_ct lag_app_to_first_action $controls if sample==1 & $filters & $filtersVC, absorb(ind_year_fe state_fe) vce(cluster gau)
			su made_it_to_next_round_`i'y if e(sample)==1
			local mean=r(mean)
			if `i'==1 outreg2 using "Table_IA16.xls", addstat("Mean dep var",`mean') keep(pat_clm_ct lag_app_to_first_action ln_rounds_before_patent_FA) dec(3) replace noparen nocons
			else outreg2 using "Table_IA16.xls", addstat("Mean dep var",`mean') keep(pat_clm_ct lag_app_to_first_action ln_rounds_before_patent_FA) dec(3) append noparen nocons
	drop sample
}
* Col. 6: IPOs
global controls="ln_rounds_before_patent_FA"
xi: reghdfe IPO $controls (pat_clm_ct lag_app_to_first_action=instrument_lag instrument_ind_claims) if $filters, absorb(ind_year_fe state_fe) vce(cluster gau) old
		local KPFstat=e(widstat)
		su IPO if e(sample)==1
		local mean=r(mean)
		outreg2 using "Table6.xls", dec(3) addstat("KP F-stat",`KPFstat',"Mean dep var",`mean') keep(pat_clm_ct lag_app_to_first_action ln_rounds_before_patent_FA) sortvar(pat_clm_ct lag_app_to_first_action ln_rounds_before_patent_FA) append noparen nor2
		g sample=e(sample)
xi: reghdfe IPO pat_clm_ct lag_app_to_first_action $controls if sample==1 & $filters, absorb(ind_year_fe state_fe) vce(cluster gau)
	su IPO if e(sample)==1
	local mean=r(mean)
	outreg2 using "Table_IA16.xls", addstat("Mean dep var",`mean') keep(pat_clm_ct lag_app_to_first_action ln_rounds_before_patent_FA) sortvar(pat_clm_ct lag_app_to_first_action ln_rounds_before_patent_FA) dec(3) append noparen nocons
drop sample



***************
*** TABLE 7 ***
***************

use HLR_data, clear
foreach var of varlist ln_total_patents_appl ln_total_patents_approved approval_rate ln_all_cites5 ln_mean_cites5 { 
	xi: reghdfe `var' (pat_clm_ct lag_app_to_first_action=instrument_lag instrument_ind_claims) if $filters, absorb(ind_year_fe state_fe) vce(cluster gau) old
		local KPFstat=e(widstat)
		if "`var'"=="ln_total_patents_appl" su total_patents_appl if e(sample)==1
		if "`var'"=="ln_total_patents_approved" su total_patents_approved if e(sample)==1
		if "`var'"=="approval_rate" su approval_rate if e(sample)==1
		if "`var'"=="ln_all_cites5" su all_cites5 if e(sample)==1
		if "`var'"=="ln_mean_cites5" su mean_cites5 if e(sample)==1
		local mean=r(mean)
		outreg2 using "Table7.xls", dec(3) addstat("KP F-stat",`KPFstat',"Mean dep var",`mean') keep(pat_clm_ct lag_app_to_first_action) sortvar(pat_clm_ct lag_app_to_first_action) append noparen nor2
		g SAMPLE=e(sample)
	quietly reghdfe `var' pat_clm_ct lag_app_to_first_action if $filters & SAMPLE==1, absorb(ind_year_fe state_fe) vce(cluster gau)
		local KPFstat=e(widstat)
		if "`var'"=="ln_total_patents_appl" su total_patents_appl if e(sample)==1
		if "`var'"=="ln_total_patents_approved" su total_patents_approved if e(sample)==1
		if "`var'"=="approval_rate" su approval_rate if e(sample)==1
		if "`var'"=="ln_all_cites5" su all_cites5 if e(sample)==1
		if "`var'"=="ln_mean_cites5" su mean_cites5 if e(sample)==1
		local mean=r(mean)
		outreg2 using "Table_IA17.xls", dec(3) addstat("Mean dep var",`mean') keep(pat_clm_ct lag_app_to_first_action) sortvar(pat_clm_ct lag_app_to_first_action) append noparen nocons
	drop SAMPLE
}




***************
*** TABLE 8 ***
***************

use HLR_data, clear
foreach j in SC {
	foreach var in emp sales {
		forvalues i= 1(1)5 {
			reghdfe `j'_ind_GROWTH`i'_`var' (pat_clm_ct lag_app_to_first_action=instrument_lag instrument_ind_claims) if $filters, absorb(`j'_num ind_year_fe) vce(cluster `j'_num) old
				local KPFstat=e(widstat)
				su `j'_ind_GROWTH`i'_`var' if e(sample)==1
				local mean=r(mean)
				g SAMPLE=e(sample)
				outreg2 using "Table8.xls", dec(3) addstat("KP F-stat",`KPFstat',"Mean dep var",`mean') keep(pat_clm_ct lag_app_to_first_action) sortvar(pat_clm_ct lag_app_to_first_action) append noparen nor2
			quietly reghdfe `j'_ind_GROWTH`i'_`var' pat_clm_ct lag_app_to_first_action if SAMPLE==1 & $filters, absorb(`j'_num ind_year_fe) vce(cluster `j'_num) old
				su `j'_ind_GROWTH`i'_`var' if e(sample)==1
				local mean=r(mean)
				outreg2 using "Table_IA22.xls", dec(3) addstat("Mean dep var",`mean') keep(pat_clm_ct lag_app_to_first_action) sortvar(pat_clm_ct lag_app_to_first_action) append noparen
			drop SAMPLE
		}
	}
}

foreach j in SC {
	forvalues i= 1(1)5 {
		reghdfe `j'_ind_survival_frac`i' (pat_clm_ct lag_app_to_first_action=instrument_lag instrument_ind_claims) if $filters, absorb(`j'_num ind_year_fe) vce(cluster `j'_num) old
				local KPFstat=e(widstat)
				su `j'_ind_survival_frac`i' if e(sample)==1
				local mean=r(mean)
				g SAMPLE=e(sample)
				outreg2 using "Table8.xls", dec(3) addstat("KP F-stat",`KPFstat',"Mean dep var",`mean') keep(pat_clm_ct lag_app_to_first_action) sortvar(pat_clm_ct lag_app_to_first_action) append noparen nor2
		quietly reghdfe `j'_ind_survival_frac`i' pat_clm_ct lag_app_to_first_action if SAMPLE==1 & $filters, absorb(`j'_num ind_year_fe) vce(cluster `j'_num) old
				su `j'_ind_survival_frac`i' if e(sample)==1
				local mean=r(mean)
				outreg2 using "Table_IA22.xls", dec(3) addstat("Mean dep var",`mean') keep(pat_clm_ct lag_app_to_first_action) sortvar(pat_clm_ct lag_app_to_first_action) append noparen
		drop SAMPLE
	}
}


***************
*** TABLE 9 ***
***************

use HLR_data, clear
foreach j in SC {
forvalues i=1/5 {
		reghdfe `j'_ind_made_it_to_next_round_`i'y (pat_clm_ct lag_app_to_first_action=instrument_lag instrument_ind_claims) if $filters & $filtersVC, absorb(`j'_num ind_year_fe) vce(cluster `j'_num) old
				local KPFstat=e(widstat)
				su `j'_ind_made_it_to_next_round_`i'y if e(sample)==1
				local mean=r(mean)
				g SAMPLE=e(sample)
				outreg2 using "Table9.xls", dec(4) addstat("KP F-stat",`KPFstat',"Mean dep var",`mean') keep(pat_clm_ct lag_app_to_first_action) sortvar(pat_clm_ct lag_app_to_first_action) append noparen nor2
		quietly reghdfe `j'_ind_made_it_to_next_round_`i'y pat_clm_ct lag_app_to_first_action if SAMPLE==1, absorb(`j'_num ind_year_fe) vce(cluster `j'_num) old
				su `j'_ind_made_it_to_next_round_`i'y if e(sample)==1
				local mean=r(mean)
				outreg2 using "Table_IA23.xls", dec(4) addstat("Mean dep var",`mean') keep(pat_clm_ct lag_app_to_first_action) sortvar(pat_clm_ct lag_app_to_first_action) append noparen
		drop SAMPLE
	}
}

foreach j in SC {
	foreach var in IPO {
		reghdfe `j'_ind_`var' (pat_clm_ct lag_app_to_first_action=instrument_lag instrument_ind_claims) if $filters, absorb(`j'_num ind_year_fe) vce(cluster `j'_num) old
				local KPFstat=e(widstat)
				su `j'_ind_`var' if e(sample)==1
				local mean=r(mean)
				g SAMPLE=e(sample)
				outreg2 using "Table9.xls", dec(4) addstat("KP F-stat",`KPFstat',"Mean dep var",`mean') keep(pat_clm_ct lag_app_to_first_action) sortvar(pat_clm_ct lag_app_to_first_action) append noparen nor2
		quietly reghdfe `j'_ind_`var' pat_clm_ct lag_app_to_first_action if SAMPLE==1 & $filters, absorb(`j'_num ind_year_fe) vce(cluster `j'_num) old
				su `j'_ind_`var' if e(sample)==1
				local mean=r(mean)
				outreg2 using "Table_IA23.xls", dec(4) addstat("Mean dep var",`mean') keep(pat_clm_ct lag_app_to_first_action) sortvar(pat_clm_ct lag_app_to_first_action) append noparen
		drop SAMPLE
	}
}


****************
*** TABLE 10 ***
****************

use HLR_data, clear
foreach j in SC {
	rename `j'_ind_total_patents_approved `j'_ind_total_patents_app
}
foreach j in SC {
	foreach var in ind_total_patents_appl ind_total_patents_app ind_all_cites5 ind_mean_cites5 {
		g `j'_ln_`var'=ln(`j'_`var'+1)
	}
}
foreach j in SC {
	foreach var in ln_ind_total_patents_appl ln_ind_total_patents_app ind_approval_rate ln_ind_all_cites5 ln_ind_mean_cites5 {
		reghdfe `j'_`var' (pat_clm_ct lag_app_to_first_action=instrument_lag instrument_ind_claims) if $filters, absorb(`j'_num ind_year_fe) vce(cluster `j'_num) old
				local KPFstat=e(widstat)
				if "`var'"=="ln_ind_total_patents_appl" su `j'_ind_total_patents_appl if e(sample)==1
				if "`var'"=="ln_ind_total_patents_app" su `j'_ind_total_patents_app if e(sample)==1
				if "`var'"=="ind_approval_rate" su `j'_ind_approval_rate if e(sample)==1
				if "`var'"=="ln_ind_all_cites5" su `j'_ind_all_cites5 if e(sample)==1
				if "`var'"=="ln_ind_mean_cites5" su `j'_ind_mean_cites5 if e(sample)==1
				local mean=r(mean)				
				g SAMPLE=e(sample)
				outreg2 using "Table10.xls", dec(3) addstat("KP F-stat",`KPFstat',"Mean dep var",`mean') keep(pat_clm_ct lag_app_to_first_action) sortvar(pat_clm_ct lag_app_to_first_action) append noparen nor2
		quietly reghdfe `j'_`var' pat_clm_ct lag_app_to_first_action if SAMPLE==1 & $filters, absorb(`j'_num ind_year_fe) vce(cluster `j'_num) old
				if "`var'"=="ln_ind_total_patents_appl" su `j'_ind_total_patents_appl if e(sample)==1
				if "`var'"=="ln_ind_total_patents_app" su `j'_ind_total_patents_app if e(sample)==1
				if "`var'"=="ind_approval_rate" su `j'_ind_approval_rate if e(sample)==1
				if "`var'"=="ln_ind_all_cites5" su `j'_ind_all_cites5 if e(sample)==1
				if "`var'"=="ln_ind_mean_cites5" su `j'_ind_mean_cites5 if e(sample)==1
				local mean=r(mean)	
				outreg2 using "Table_IA24.xls", dec(3) addstat("Mean dep var",`mean') keep(pat_clm_ct lag_app_to_first_action) sortvar(pat_clm_ct lag_app_to_first_action) append noparen
		drop SAMPLE
	}
}


******************
*** TABLE IA.2 ***
******************

use HLR_data, clear
foreach var in emp sales {
	forvalues i= 1(1)5 {
		global controls="ln_initial_`var' lenience"
		reghdfe growth`i'_`var'_w $controls (pat_clm_ct lag_app_to_first_action=instrument_lag instrument_ind_claims) if $filters, absorb(i.state_num ind_year_fe) cluster(gau) old
				local KPFstat=e(widstat)
				su growth`i'_`var'_w if e(sample)==1
				local mean=r(mean)
				outreg2 using "Table_IA2.xls", dec(3) addstat("KP F-stat",`KPFstat',"Mean dep var",`mean') sortvar(pat_clm_ct lag_app_to_first_action lenience) keep(pat_clm_ct lag_app_to_first_action lenience) append noparen nor2
	}
}
forvalues i=1(1)5 {
	global controls="ln_initial_emp lenience"
	reghdfe survive`i' $controls (pat_clm_ct lag_app_to_first_action=instrument_lag instrument_ind_claims) if $filters, absorb(i.state_num ind_year_fe) cluster(gau) old
				local KPFstat=e(widstat)
				su survive`i' if e(sample)==1
				local mean=r(mean)
				outreg2 using "Table_IA2.xls", dec(3) addstat("KP F-stat",`KPFstat',"Mean dep var",`mean') sortvar(pat_clm_ct lag_app_to_first_action lenience) keep(pat_clm_ct lag_app_to_first_action lenience) append noparen nor2
}


******************
*** TABLE IA.3 ***
******************

use HLR_data, clear
foreach var in emp sales {
	forvalues i= 1(1)5 {
		reghdfe growth`i'_`var'_w (pat_clm_ct lag_app_to_first_action=instrument_lag instrument_ind_claims) if $filters, absorb(ind_year_fe) cluster(gau) old
				local KPFstat=e(widstat)
				su growth`i'_`var'_w if e(sample)==1
				local mean=r(mean)
				outreg2 using "Table_IA3.xls", dec(3) addstat("KP F-stat",`KPFstat',"Mean dep var",`mean') sortvar(pat_clm_ct lag_app_to_first_action) keep(pat_clm_ct lag_app_to_first_action) append noparen nor2
	}
}
forvalues i=1(1)5 {
	reghdfe survive`i' (pat_clm_ct lag_app_to_first_action=instrument_lag instrument_ind_claims) if $filters, absorb(ind_year_fe) cluster(gau) old
				local KPFstat=e(widstat)
				su survive`i' if e(sample)==1
				local mean=r(mean)
				outreg2 using "Table_IA3.xls", dec(3) addstat("KP F-stat",`KPFstat',"Mean dep var",`mean') sortvar(pat_clm_ct lag_app_to_first_action) keep(pat_clm_ct lag_app_to_first_action) append noparen nor2
}


******************
*** TABLE IA.4 ***
******************

use HLR_data, clear
g impute_pub_clm_ct=(pub_clm_ct==.)
g pub_clm_ct_v1=pub_clm_ct
replace pub_clm_ct_v1=pat_clm_ct if pub_clm_ct==.

foreach var in emp sales {
	forvalues i= 1(1)5 {
		global controls="ln_initial_`var' pub_clm_ct_v1 impute_pub_clm_ct"
		reghdfe growth`i'_`var'_w $controls (pat_clm_ct lag_app_to_first_action=instrument_lag instrument_ind_claims) if $filters, absorb(i.state_num ind_year_fe) cluster(gau) old
				local KPFstat=e(widstat)
				su growth`i'_`var'_w if e(sample)==1
				local mean=r(mean)
				outreg2 using "Table_IA4.xls", dec(3) addstat("KP F-stat",`KPFstat',"Mean dep var",`mean') sortvar(pat_clm_ct lag_app_to_first_action pub_clm_ct_v1) keep(pat_clm_ct lag_app_to_first_action pub_clm_ct_v1) append noparen nor2
	}
}
forvalues i=1(1)5 {
	global controls="ln_initial_emp pub_clm_ct_v1 impute_pub_clm_ct"
	reghdfe survive`i' $controls (pat_clm_ct lag_app_to_first_action=instrument_lag instrument_ind_claims) if $filters, absorb(i.state_num ind_year_fe) cluster(gau) old
				local KPFstat=e(widstat)
				su survive`i' if e(sample)==1
				local mean=r(mean)
				outreg2 using "Table_IA4.xls", dec(3) addstat("KP F-stat",`KPFstat',"Mean dep var",`mean') sortvar(pat_clm_ct lag_app_to_first_action pub_clm_ct_v1) keep(pat_clm_ct lag_app_to_first_action pub_clm_ct_v1) append noparen nor2
}


******************
*** TABLE IA.5 ***
******************

use HLR_data, clear
foreach var in emp sales {
	forvalues i= 1(1)5 {
		global controls=" ln_initial_`var'"
		reghdfe growth`i'_`var'_w $controls (tot_clm_ct lag_app_to_first_action=instrument_lag instrument_tot_claims) if $filters, absorb(i.state_num ind_year_fe) cluster(gau) old
				local KPFstat=e(widstat)
				su growth`i'_`var'_w if e(sample)==1
				local mean=r(mean)
				outreg2 using "Table_IA5.xls", dec(3) addstat("KP F-stat",`KPFstat',"Mean dep var",`mean') sortvar(tot_clm_ct lag_app_to_first_action) keep(tot_clm_ct lag_app_to_first_action) append noparen nor2
	}
}
forvalues i=1(1)5 {
	global controls="ln_initial_emp"
	reghdfe survive`i' $controls (tot_clm_ct lag_app_to_first_action=instrument_lag instrument_tot_claims ) if $filters, absorb(i.state_num ind_year_fe) cluster(gau) old
				local KPFstat=e(widstat)
				su survive`i' if e(sample)==1
				local mean=r(mean)
				outreg2 using "Table_IA5.xls", dec(3) addstat("KP F-stat",`KPFstat',"Mean dep var",`mean') sortvar(tot_clm_ct lag_app_to_first_action) keep(tot_clm_ct lag_app_to_first_action) append noparen nor2
}


******************
*** TABLE IA.6 ***
******************

use HLR_data, clear
foreach var in emp sales {
	forvalues i= 1(1)5 {
		global controls=" ln_initial_`var'"
		reghdfe growth`i'_`var'_w $controls (patent_scope_z_score_within_art_ lag_app_to_first_action=instrument_lag examiner_scope_toughness_z_score) if $filters, absorb(i.state_num ind_year_fe) cluster(gau) old
				local KPFstat=e(widstat)
				su growth`i'_`var'_w if e(sample)==1
				local mean=r(mean)
				outreg2 using "Table_IA6.xls", dec(3) addstat("KP F-stat",`KPFstat',"Mean dep var",`mean') keep(patent_scope_z_score_within_art_ lag_app_to_first_action) append noparen nor2
	}
}
forvalues i=1(1)5 {
	global controls="ln_initial_emp"
	reghdfe survive`i' $controls (patent_scope_z_score_within_art_ lag_app_to_first_action=instrument_lag examiner_scope_toughness_z_score ) if $filters, absorb(i.state_num ind_year_fe) cluster(gau) old
				local KPFstat=e(widstat)
				su survive`i' if e(sample)==1
				local mean=r(mean)
				outreg2 using "Table_IA6.xls", dec(3) addstat("KP F-stat",`KPFstat',"Mean dep var",`mean') keep(patent_scope_z_score_within_art_ lag_app_to_first_action) append noparen nor2
}



******************
*** TABLE IA.7 ***
******************

use HLR_data, clear
foreach var in emp sales {
	forvalues i= 1(1)5 {
		global controls="ln_initial_`var'"
		reghdfe growth`i'_`var'_w $controls (pat_clm_ct lag_app_to_first_action=instrument_lag instrument_pdif_claims) if $filters, absorb(i.state_num ind_year_fe) cluster(gau) old
				local KPFstat=e(widstat)
				su growth`i'_`var'_w if e(sample)==1
				local mean=r(mean)
				outreg2 using "Table_IA7.xls", dec(3) addstat("KP F-stat",`KPFstat',"Mean dep var",`mean') sortvar(pat_clm_ct lag_app_to_first_action) keep(pat_clm_ct lag_app_to_first_action) append noparen nor2
	}
}

forvalues i=1(1)5 {
	global controls="ln_initial_emp"
	reghdfe survive`i' $controls (pat_clm_ct lag_app_to_first_action=instrument_lag instrument_pdif_claims) if $filters, absorb(i.state_num ind_year_fe) cluster(gau) old
				local KPFstat=e(widstat)
				su survive`i' if e(sample)==1
				local mean=r(mean)
				outreg2 using "Table_IA7.xls", dec(3) addstat("KP F-stat",`KPFstat',"Mean dep var",`mean') sortvar(pat_clm_ct lag_app_to_first_action) keep(pat_clm_ct lag_app_to_first_action) append noparen nor2
}


******************
*** TABLE IA.8 ***
******************

use HLR_data, clear
foreach var in emp sales {
	forvalues i= 1(1)5 {
		global controls="ln_initial_`var'"
		reghdfe growth`i'_`var'_w $controls (pat_clm_ct lag_app_to_first_action=instrument_lag instrument_ind_claims) if $filters, absorb(i.state_num ind_year_fe techsc_year_fe) cluster(gau) old
				local KPFstat=e(widstat)
				su growth`i'_`var'_w if e(sample)==1
				local mean=r(mean)
				outreg2 using "Table_IA8.xls", dec(3) addstat("KP F-stat",`KPFstat',"Mean dep var",`mean') sortvar(pat_clm_ct lag_app_to_first_action) keep(pat_clm_ct lag_app_to_first_action) append noparen nor2
	}
}
forvalues i=1(1)5 {
	global controls="ln_initial_emp"
	reghdfe survive`i' $controls (pat_clm_ct lag_app_to_first_action=instrument_lag instrument_ind_claims) if $filters, absorb(i.state_num ind_year_fe techsc_year_fe) cluster(gau) old
				local KPFstat=e(widstat)
				su survive`i' if e(sample)==1
				local mean=r(mean)
				outreg2 using "Table_IA8.xls", dec(3) addstat("KP F-stat",`KPFstat',"Mean dep var",`mean') sortvar(pat_clm_ct lag_app_to_first_action) keep(pat_clm_ct lag_app_to_first_action) append noparen nor2
}


******************
*** TABLE IA.9 ***
******************

use HLR_data, clear
foreach var in emp sales {
	forvalues i= 1(1)5 {
		global controls="ln_initial_`var'"
		reghdfe growth`i'_`var'_w $controls (pat_clm_ct lag_app_to_first_action=instrument_lag instrument_ind_claims) if $filters & rce==0, absorb(i.state_num ind_year_fe) cluster(gau) old
				local KPFstat=e(widstat)
				su growth`i'_`var'_w if e(sample)==1
				local mean=r(mean)
				outreg2 using "Table_IA9.xls", dec(3) addstat("KP F-stat",`KPFstat',"Mean dep var",`mean') sortvar(pat_clm_ct lag_app_to_first_action) keep(pat_clm_ct lag_app_to_first_action) append noparen nor2
	}
}
forvalues i=1(1)5 {
	global controls="ln_initial_emp"
	reghdfe survive`i' $controls (pat_clm_ct lag_app_to_first_action=instrument_lag instrument_ind_claims) if $filters & rce==0, absorb(i.state_num ind_year_fe) cluster(gau) old
				local KPFstat=e(widstat)
				su survive`i' if e(sample)==1
				local mean=r(mean)
				outreg2 using "Table_IA9.xls", dec(3) addstat("KP F-stat",`KPFstat',"Mean dep var",`mean') sortvar(pat_clm_ct lag_app_to_first_action) keep(pat_clm_ct lag_app_to_first_action) append noparen nor2
}


*******************
*** TABLE IA.10 ***
*******************

use HLR_data, clear
foreach var in emp sales {
	forvalues i= 1(1)5 {
		global controls="ln_initial_`var'"
		reghdfe growth`i'_`var'_w $controls (pat_clm_ct lag_app_to_first_action=instrument_lag instrument_ind_claims) if $filters & continuation_child==0, absorb(i.state_num ind_year_fe) cluster(gau) old
				local KPFstat=e(widstat)
				su growth`i'_`var'_w if e(sample)==1
				local mean=r(mean)
				outreg2 using "Table_IA10.xls", dec(3) addstat("KP F-stat",`KPFstat',"Mean dep var",`mean') sortvar(pat_clm_ct lag_app_to_first_action) keep(pat_clm_ct lag_app_to_first_action) append noparen nor2
	}
}
forvalues i=1(1)5 {
	global controls="ln_initial_emp"
	reghdfe survive`i' $controls (pat_clm_ct lag_app_to_first_action=instrument_lag instrument_ind_claims) if $filters & continuation_child==0, absorb(i.state_num ind_year_fe) cluster(gau) old
				local KPFstat=e(widstat)
				su survive`i' if e(sample)==1
				local mean=r(mean)
				outreg2 using "Table_IA10.xls", dec(3) addstat("KP F-stat",`KPFstat',"Mean dep var",`mean') sortvar(pat_clm_ct lag_app_to_first_action) keep(pat_clm_ct lag_app_to_first_action) append noparen nor2
}
	

*******************
*** TABLE IA.11 ***
*******************

use HLR_data, clear
g pat_clm_ct_ccd=pat_clm_ct
	replace pat_clm_ct_ccd=ccd_pat_clm_ct if pat_clm_ct_ccd==.
g pat_approved_ccd=patent_approved
	replace pat_approved_ccd=1 if pat_approved_ccd==0 & ccd_appl_id!=""

foreach var in emp sales {
	forvalues i= 1(1)5 {
		global controls="ln_initial_`var'"
		reghdfe growth`i'_`var'_w $controls (pat_clm_ct_ccd lag_app_to_first_action=instrument_lag instrument_ind_claims) if $filtersCCD, absorb(i.state_num ind_year_fe) cluster(gau) old
				local KPFstat=e(widstat)
				su growth`i'_`var'_w if e(sample)==1
				local mean=r(mean)
				outreg2 using "Table_IA11.xls", dec(3) addstat("KP F-stat",`KPFstat',"Mean dep var",`mean') keep(pat_clm_ct_ccd lag_app_to_first_action) append noparen nor2
	}
}
forvalues i=1(1)5 {
	global controls="ln_initial_emp"
	reghdfe survive`i' $controls (pat_clm_ct_ccd lag_app_to_first_action=instrument_lag instrument_ind_claims ) if $filtersCCD, absorb(i.state_num ind_year_fe) cluster(gau) old
				local KPFstat=e(widstat)
				su survive`i' if e(sample)==1
				local mean=r(mean)
				outreg2 using "Table_IA11.xls", dec(3) addstat("KP F-stat",`KPFstat',"Mean dep var",`mean') keep(pat_clm_ct_ccd lag_app_to_first_action) append noparen nor2
}


*******************
*** TABLE IA.12 ***
*******************

use HLR_data, clear
foreach var in emp sales {
	forvalues i= 1(1)5 {
		global controls="ln_initial_`var'"
		reghdfe growth`i'_`var'_w $controls (pat_clm_ct lag_app_to_first_action=instrument_lag_nc instrument_ind_claims_nc) if $filtersNC, absorb(i.state_num ind_year_fe) cluster(gau) old
				local KPFstat=e(widstat)
				su growth`i'_`var'_w if e(sample)==1
				local mean=r(mean)
				outreg2 using "Table_IA12.xls", dec(3) addstat("KP F-stat",`KPFstat',"Mean dep var",`mean') sortvar(pat_clm_ct lag_app_to_first_action) keep(pat_clm_ct lag_app_to_first_action) append noparen nor2
	}
}
forvalues i=1(1)5 {
	global controls="ln_initial_emp"
	reghdfe survive`i' $controls (pat_clm_ct lag_app_to_first_action=instrument_lag_nc instrument_ind_claims_nc ) if $filtersNC, absorb(i.state_num ind_year_fe) cluster(gau) old
				local KPFstat=e(widstat)
				su survive`i' if e(sample)==1
				local mean=r(mean)
				outreg2 using "Table_IA12.xls", dec(3) addstat("KP F-stat",`KPFstat',"Mean dep var",`mean') sortvar(pat_clm_ct lag_app_to_first_action) keep(pat_clm_ct lag_app_to_first_action) append noparen nor2
}
	

*******************
*** TABLE IA.13 ***
*******************

use HLR_data, clear
tab accelerated
foreach var in emp sales {
	forvalues i= 1(1)5 {
		global controls="ln_initial_`var'"
		reghdfe growth`i'_`var'_w $controls (pat_clm_ct lag_app_to_first_action=instrument_lag instrument_ind_claims) if $filters & accelerated==0, absorb(i.state_num ind_year_fe) cluster(gau) old
				local KPFstat=e(widstat)
				su growth`i'_`var'_w if e(sample)==1
				local mean=r(mean)
				outreg2 using "Table_IA13.xls", dec(3) addstat("KP F-stat",`KPFstat',"Mean dep var",`mean') sortvar(pat_clm_ct lag_app_to_first_action) keep(pat_clm_ct lag_app_to_first_action) append noparen nor2
	}
}
forvalues i=1(1)5 {
	global controls="ln_initial_emp"
	reghdfe survive`i' $controls (pat_clm_ct lag_app_to_first_action=instrument_lag instrument_ind_claims) if $filters & accelerated==0, absorb(i.state_num ind_year_fe) cluster(gau) old
				local KPFstat=e(widstat)
				su survive`i' if e(sample)==1
				local mean=r(mean)
				outreg2 using "Table_IA13.xls", dec(3) addstat("KP F-stat",`KPFstat',"Mean dep var",`mean') sortvar(pat_clm_ct lag_app_to_first_action) keep(pat_clm_ct lag_app_to_first_action) append noparen nor2
}
		
		
*******************
*** TABLE IA.14 ***
*******************

use HLR_data, clear
g international=appl_eu
	replace international=appl_jp if international==0

foreach var in emp sales {
	forvalues i= 1(1)5 {
		global controls="ln_initial_`var'"
		reghdfe growth`i'_`var'_w $controls (pat_clm_ct lag_app_to_first_action=instrument_lag instrument_ind_claims) if $filters & international==0, absorb(i.state_num ind_year_fe) cluster(gau) old
				local KPFstat=e(widstat)
				su growth`i'_`var'_w if e(sample)==1
				local mean=r(mean)
				outreg2 using "Table_IA14.xls", dec(3) addstat("KP F-stat",`KPFstat',"Mean dep var",`mean') sortvar(pat_clm_ct lag_app_to_first_action) keep(pat_clm_ct lag_app_to_first_action) append noparen nor2
	}
}
forvalues i=1(1)5 {
	global controls="ln_initial_emp"
	reghdfe survive`i' $controls (pat_clm_ct lag_app_to_first_action=instrument_lag instrument_ind_claims) if $filters & international==0, absorb(i.state_num ind_year_fe) cluster(gau) old
				local KPFstat=e(widstat)
				su survive`i' if e(sample)==1
				local mean=r(mean)
				outreg2 using "Table_IA14.xls", dec(3) addstat("KP F-stat",`KPFstat',"Mean dep var",`mean') sortvar(pat_clm_ct lag_app_to_first_action) keep(pat_clm_ct lag_app_to_first_action) append noparen nor2
}
		

*******************
*** TABLE IA.15 ***
*******************

use HLR_data, clear
foreach var in emp sales {
	forvalues i= 1(1)5{
		global controls="ln_initial_`var'"
		g nets_imputed=growth`i'_`var'_imp
		g delay_imputed=nets_imputed*lag_app_to_first_action
		g delay_not_imputed=(1-nets_imputed)*lag_app_to_first_action
		g scope_imputed=nets_imputed*pat_clm_ct
		g scope_not_imputed=(1-nets_imputed)*pat_clm_ct
		g instrument_lag_imputed=instrument_lag*nets_imputed
		g instrument_lag_not_imputed=(1-nets_imputed)*instrument_lag
		g instrument_clms_imputed=instrument_ind_claims*nets_imputed
		g instrument_clms_not_imputed=(1-nets_imputed)*instrument_ind_claims

		reghdfe growth`i'_`var'_w $controls (scope_not_imputed scope_imputed delay_not_imputed delay_imputed=instrument_lag_imputed instrument_lag_not_imputed instrument_clms_imputed instrument_clms_not_imputed) if $filters, absorb(i.state_num ind_year_fe) cluster(gau) old
				local KPFstat=e(widstat)
				su growth`i'_`var'_w if e(sample)==1
				local mean=r(mean)
				outreg2 using "Table_IA15.xls", dec(3) addstat("KP F-stat",`KPFstat',"Mean dep var",`mean') keep(scope_not_imputed scope_imputed delay_not_imputed delay_imputed) append noparen nor2
		drop nets_imputed
		drop delay_imputed delay_not_imputed scope_imputed scope_not_imputed instrument_lag_imputed instrument_lag_not_imputed instrument_clms_imputed instrument_clms_not_imputed
	}
}
	

*******************
*** TABLE IA.18 ***
*******************

use rejected_data, clear
foreach var in emp sales {
	forvalues i= 1(1)5 {
		global controls="ln_initial_`var'"
		reghdfe growth`i'_`var'_w $controls (lag_app_to_first_action=instrument_lag) if $filtersRejected, absorb(i.state_num ind_year_fe) cluster(gau) old
				local KPFstat=e(widstat)
				su growth`i'_`var'_w if e(sample)==1
				local mean=r(mean)
				outreg2 using "Table_IA18.xls", dec(3) addstat("KP F-stat",`KPFstat',"Mean dep var",`mean') keep(lag_app_to_first_action) append noparen nor2
	}
}

forvalues i=1(1)5 {
	global controls="ln_initial_emp"
	reghdfe survive`i' $controls (lag_app_to_first_action=instrument_lag ) if $filtersRejected, absorb(i.state_num ind_year_fe) cluster(gau) old
				local KPFstat=e(widstat)
				su survive`i' if e(sample)==1
				local mean=r(mean)
				outreg2 using "Table_IA18.xls", dec(3) addstat("KP F-stat",`KPFstat',"Mean dep var",`mean') keep(lag_app_to_first_action) append noparen nor2
}

	
*******************
*** TABLE IA.19 ***
*******************

use rejected_data, clear

* Cols. 1-5: VC funding
forvalues i=1/5 {
	global controls="ln_rounds_before_patent_FA"
	global filtersVC="!(made_it_to_next_round_`i'y==0 & first_pat_act_date+365.25*`i'>= Exit_Date)"
	reghdfe made_it_to_next_round_`i'y $controls (lag_app_to_first_action=instrument_lag) if $filtersRejected & $filtersVC & patent_approved==0, absorb(ind_year_fe state_fe) vce(cluster gau) old
				local KPFstat=e(widstat)
				su made_it_to_next_round_`i'y if e(sample)==1
				local mean=r(mean)
				outreg2 using "Table_IA19.xls", dec(3) addstat("KP F-stat",`KPFstat',"Mean dep var",`mean') keep(lag_app_to_first_action ln_rounds_before_patent_FA) append noparen nor2
}
* Col. 6: IPOs	
global controls="ln_rounds_before_patent_FA"
reghdfe IPO $controls (lag_app_to_first_action=instrument_lag) if $filtersRejected, absorb(ind_year_fe state_fe) vce(cluster gau) old
	estimates store IPO
				local KPFstat=e(widstat)
				su IPO if e(sample)==1
				local mean=r(mean)
				outreg2 using "Table_IA19.xls", dec(3) addstat("KP F-stat",`KPFstat',"Mean dep var",`mean') keep(lag_app_to_first_action ln_rounds_before_patent_FA) append noparen nor2



*******************
*** TABLE IA.20 ***
*******************

use rejected_data, clear
foreach var of varlist ln_total_patents_appl ln_total_patents_approved approval_rate ln_all_cites5 ln_mean_cites5 { 
	reghdfe `var' (lag_app_to_first_action=instrument_lag) if $filtersRejected, absorb(ind_year_fe state_fe) vce(cluster gau) old
		estimates store `var'
				local KPFstat=e(widstat)
				if "`var'"=="ln_total_patents_appl" su total_patents_appl if e(sample)==1
				if "`var'"=="ln_total_patents_approved" su total_patents_approved if e(sample)==1
				if "`var'"=="approval_rate" su approval_rate if e(sample)==1
				if "`var'"=="ln_all_cites5" su all_cites5 if e(sample)==1
				if "`var'"=="ln_mean_cites5" su mean_cites5 if e(sample)==1
				local mean=r(mean)
				outreg2 using "Table_IA20.xls", dec(3) addstat("KP F-stat",`KPFstat',"Mean dep var",`mean') keep(lag_app_to_first_action) append noparen nor2
}


****************************
*** FIGURE IA.1, PANEL A ***
****************************

use HLR_FigIA1a_Data, clear
grstyle init
grstyle color background white
twoway line min95_ estimate_ max95_ year if parm=="lag_app_to_first_action", subtitle(,fcolor(white) bc(white) size(large)) by(dv, legend(off) yrescale note("") graphregion(fcolor(white)) iy ix rows(1)) legend(off) lc(black black black) lp(dash solid dash) xtitle("Year") graphregion(ifcolor(white)) graphregion(fcolor(white)) yline(0)
graph display, ysize(3) xsize(6)


****************************
*** FIGURE IA.1, PANEL B ***
****************************

grstyle init
grstyle color background white
coefplot IPO, bylabel (Filed IPO) || (ln_total_patents_appl), bylabel(Log Patent Applications) || (ln_total_patents_approved), bylabel(Log Patent Approved) || (approval_rate), bylabel(Patent Approval Rate) || (ln_all_cites5), bylabel(Log Citations to Patent Applications) || (ln_mean_cites5), bylabel(Log Citations per Application) ||, drop(avg_clm_wrd_ct pub_clm_ct ln_rounds_before_patent_FA) xline(0) bycoefs byopts(xrescale) graphregion(fcolor(white)) leg(off)
graph display, ysize(3) 


*******************
*** TABLE IA.21 ***
*******************

use second_patent_data, clear
foreach var in emp sales {
	forvalues i= 1(1)5 {
		global controls=" ln_initial_`var' dallowed_1"
		reghdfe growth`i'_`var'_w $controls (pat_clm_ct lag_app_to_first_action=instrument_lag instrument_ind_claims) if $filters, absorb(i.state_num ind_year_fe) cluster(gau) old
				local KPFstat=e(widstat)
				su growth`i'_`var'_w if e(sample)==1
				local mean=r(mean)
				outreg2 using "Table_IA21.xls", dec(3) addstat("KP F-stat",`KPFstat',"Mean dep var",`mean') keep(pat_clm_ct lag_app_to_first_action) append noparen nor2
	}
}
su growth1_emp_w growth2_emp_w growth3_emp_w growth4_emp_w growth5_emp_w growth1_sales_w growth2_sales_w growth3_sales_w growth4_sales_w growth5_sales_w if (patent_approved==1 & pat_clm_ct!=. & lag_app_to_first_action!=.)

forvalues i=1(1)5 {
	global controls="ln_initial_emp"
	reghdfe survive`i' $controls (pat_clm_ct lag_app_to_first_action=instrument_lag instrument_ind_claims) if $filters, absorb(i.state_num ind_year_fe) cluster(gau) old
				local KPFstat=e(widstat)
				su survive`i' if e(sample)==1
				local mean=r(mean)
				outreg2 using "Table_IA21.xls", dec(3) addstat("KP F-stat",`KPFstat',"Mean dep var",`mean') keep(pat_clm_ct lag_app_to_first_action) append noparen nor2
}
su survive1-survive5 if (patent_approved==1 & pat_clm_ct!=. & lag_app_to_first_action!=.)


capture log close
